package com.example.administrator.yuejian35.Recommend.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.yuejian35.R;
import com.example.administrator.yuejian35.Recommend.bean.ShowApplyresult;
import com.example.administrator.yuejian35.Recommend.model.RecommendModel;
import com.squareup.picasso.Picasso;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import static com.example.administrator.yuejian35.Config.Img_URL;

public class ApplyInfoActivity extends AppCompatActivity {
    private TextView apply_state;
    private ImageView coursepic;
    private ImageView ic_back;
    private TextView course_name;
    private TextView course_price;
    private TextView course_time;
    private TextView course_address;
    private TextView num;
    private TextView sum;
    private TextView applyid;
    private TextView applytime;
    private String aId;
    private int s;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_apply_info);
        apply_state = (TextView) findViewById(R.id.apply_state);
        course_name= (TextView) findViewById(R.id.course_name);
        course_price = (TextView) findViewById(R.id.course_price);
        coursepic = (ImageView) findViewById(R.id.course_pic);
        ic_back = (ImageView) findViewById(R.id.video_pic);
        course_time = (TextView) findViewById(R.id.course_time);
        course_address= (TextView) findViewById(R.id.course_address);
        num = (TextView) findViewById(R.id.num);
        sum = (TextView) findViewById(R.id.sum);
        applyid= (TextView) findViewById(R.id.applyid);
        applytime = (TextView) findViewById(R.id.applytime);
        aId = getIntent().getStringExtra("applyid");
        s=getIntent().getIntExtra("sum",-1);

        ic_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        RecommendModel recommendmodel = new RecommendModel();
        Call call = recommendmodel.showapplyinfo(aId);
        call.enqueue(new Callback<ShowApplyresult>() {
            @Override
            public void onResponse(Call<ShowApplyresult> call, Response<ShowApplyresult> response) {
                ShowApplyresult a=response.body();
                if(a.getApplystate().equals("1"))
                {
                    apply_state.setText("已参加");
                }
                else{
                    apply_state.setText("未参加");
                }
                course_name.setText(a.getCoursename());
                course_price.setText(a.getPrice()+"元");
                course_time.setText("上课时间："+a.getCoursetime());
                course_address.setText("报名须知："+a.getBmnotice());
                num.setText("成人票  "+a.getNum()+"张");
                sum.setText(s+"元");
                applyid.setText("订单编号：2300415"+a.getCourseapplyid());
                applytime.setText("下单时间："+a.getApplytime());
                Picasso.with(ApplyInfoActivity.this)
                        .load(Img_URL+a.getCoursepic())
                        .into(coursepic);


            }

            @Override
            public void onFailure(Call<ShowApplyresult> call, Throwable t) {

            }
        });
    }
}
